<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Relation Kind Template</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
MathJax = {
	tex: {
		inlineMath: '$', '$'], ['\\(', '\\)'
	},
	svg: {
		fontCache: 'global'
	}
};
</script>
<script type="text/javascript" id="MathJax-script" async
	src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
</script>

<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Relation Kind Template' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../extensions.html">Kits</a></li><li><a href="index.html">BasicInformKit</a></li><li><b>Relation Kind Template</b></li></ul></div>
<p class="purpose">Code to support the relation kind.</p>

<ul class="toc"><li><a href="rkt.html#SP1">&#167;1. Block Format</a></li><li><a href="rkt.html#SP2">&#167;2. Other Definitions</a></li><li><a href="rkt.html#SP3">&#167;3. Tunable Parameters</a></li><li><a href="rkt.html#SP4">&#167;4. Abstract Relations</a></li><li><a href="rkt.html#SP5">&#167;5. Empty Relations</a></li><li><a href="rkt.html#SP6">&#167;6. Creation</a></li><li><a href="rkt.html#SP7">&#167;7. Extent</a></li><li><a href="rkt.html#SP8">&#167;8. Destruction</a></li><li><a href="rkt.html#SP9">&#167;9. Copying</a></li><li><a href="rkt.html#SP10">&#167;10. Comparison</a></li><li><a href="rkt.html#SP11">&#167;11. Printing</a></li><li><a href="rkt.html#SP12">&#167;12. Naming</a></li><li><a href="rkt.html#SP13">&#167;13. Choose Relation Handler</a></li><li><a href="rkt.html#SP14">&#167;14. Valency</a></li><li><a href="rkt.html#SP15">&#167;15. Double Hash Set Relation Handler</a></li><li><a href="rkt.html#SP16">&#167;16. Hash List Relation Handler</a></li><li><a href="rkt.html#SP17">&#167;17. Hash Table Relation Handler</a></li><li><a href="rkt.html#SP18">&#167;18. Reversed Hash Table Relation Handler</a></li><li><a href="rkt.html#SP19">&#167;19. Symmetric Relation Handlers</a></li><li><a href="rkt.html#SP20">&#167;20. Hash Core Relation Handler</a></li><li><a href="rkt.html#SP21">&#167;21. Equivalence Hash Table Relation Handler</a></li><li><a href="rkt.html#SP22">&#167;22. Two-In-One Hash Table Relation Handler</a></li><li><a href="rkt.html#SP23">&#167;23. Empty</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Block Format.</b>Inform uses a rich variety of relations, with many different data representations,
but we aim to hide that complexity from the user. At run-time, a relation is
represented by a block value. The short block of this BV is simply a pointer
to a long block. This always begins with at least six words of metadata, but
actual data sometimes follows on, and sometimes doesn't: and its format is
something the customer needn't know about.
</p>

<p class="commentary">The low-level routines in "Relations.i6t" access this metadata by direct use
of <span class="extract"><span class="extract-syntax">--&gt;</span></span>, for speed, and they use the offset constants <span class="extract"><span class="extract-syntax">RR_NAME</span></span> and so on;
but we will use the <span class="extract"><span class="extract-syntax">PVField</span></span> and <span class="extract"><span class="extract-syntax">WritePVField</span></span> routines in this
section, which need offsets in the form <span class="extract"><span class="extract-syntax">RRV_NAME</span></span>. (The discrepancy of 5 is
to allow for the five-word block header.)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRV_NAME</span><span class="plain-syntax">           </span><span class="identifier-syntax">RR_NAME</span><span class="plain-syntax">-5;        </span><span class="comment-syntax">Packed string, e.g. "containment relation"</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRV_PERMISSIONS</span><span class="plain-syntax">    </span><span class="identifier-syntax">RR_PERMISSIONS</span><span class="plain-syntax">-5; </span><span class="comment-syntax">A bitmap of what operations this supports</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">        </span><span class="identifier-syntax">RR_STORAGE</span><span class="plain-syntax">-5;     </span><span class="comment-syntax">Data location, depending on format</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRV_KIND</span><span class="plain-syntax">           </span><span class="identifier-syntax">RR_KIND</span><span class="plain-syntax">-5;        </span><span class="comment-syntax">Strong kind ID of the relation</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRV_HANDLER</span><span class="plain-syntax">        </span><span class="identifier-syntax">RR_HANDLER</span><span class="plain-syntax">-5;     </span><span class="comment-syntax">Routine to perform operations on this</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRV_DESCRIPTION</span><span class="plain-syntax">    </span><span class="identifier-syntax">RR_DESCRIPTION</span><span class="plain-syntax">-5; </span><span class="comment-syntax">Packed string, e.g. "contains"</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">           </span><span class="constant-syntax">6</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">         </span><span class="constant-syntax">7</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax">      </span><span class="constant-syntax">8</span><span class="plain-syntax">;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. Other Definitions.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="comment-syntax">valencies</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRVAL_V_TO_V</span><span class="plain-syntax">       </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRVAL_V_TO_O</span><span class="plain-syntax">       </span><span class="identifier-syntax">RELS_Y_UNIQUE</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRVAL_O_TO_V</span><span class="plain-syntax">       </span><span class="identifier-syntax">RELS_X_UNIQUE</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRVAL_O_TO_O</span><span class="plain-syntax">       </span><span class="identifier-syntax">RELS_X_UNIQUE</span><span class="plain-syntax">+</span><span class="identifier-syntax">RELS_Y_UNIQUE</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRVAL_EQUIV</span><span class="plain-syntax">        </span><span class="identifier-syntax">RELS_EQUIVALENCE</span><span class="plain-syntax">+</span><span class="identifier-syntax">RELS_SYMMETRIC</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRVAL_SYM_V_TO_V</span><span class="plain-syntax">   </span><span class="identifier-syntax">RELS_SYMMETRIC</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRVAL_SYM_O_TO_O</span><span class="plain-syntax">   </span><span class="identifier-syntax">RELS_SYMMETRIC</span><span class="plain-syntax">+</span><span class="identifier-syntax">RELS_X_UNIQUE</span><span class="plain-syntax">+</span><span class="identifier-syntax">RELS_Y_UNIQUE</span><span class="plain-syntax">;</span>

<span class="comment-syntax">dictionary entry flags</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">       </span><span class="constant-syntax">$0001</span><span class="plain-syntax">;  </span><span class="comment-syntax">entry contains a value</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRF_DELETED</span><span class="plain-syntax">    </span><span class="constant-syntax">$0002</span><span class="plain-syntax">;  </span><span class="comment-syntax">entry used to contain a value</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">     </span><span class="constant-syntax">$0004</span><span class="plain-syntax">;  </span><span class="comment-syntax">entry's Y is a value, not a list</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRF_HASX</span><span class="plain-syntax">       </span><span class="constant-syntax">$0010</span><span class="plain-syntax">;  </span><span class="comment-syntax">2-in-1 entry contains a corresponding key</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">       </span><span class="constant-syntax">$0020</span><span class="plain-syntax">;  </span><span class="comment-syntax">2-in-1 entry contains a corresponding value</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">    </span><span class="constant-syntax">$0040</span><span class="plain-syntax">;  </span><span class="comment-syntax">2-in-1 entry key is left side KOV</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">    </span><span class="constant-syntax">$0080</span><span class="plain-syntax">;  </span><span class="comment-syntax">2-in-1 entry key is right side KOV</span>

<span class="comment-syntax">permission/task constants (those commented out here are generated by I7)</span>
<span class="comment-syntax">onstant RELS_SYMMETRIC $8000;</span>
<span class="comment-syntax">onstant RELS_EQUIVALENCE $4000;</span>
<span class="comment-syntax">onstant RELS_X_UNIQUE $2000;</span>
<span class="comment-syntax">onstant RELS_Y_UNIQUE $1000;</span>
<span class="comment-syntax">onstant RELS_TEST $0800;</span>
<span class="comment-syntax">onstant RELS_ASSERT_TRUE $0400;</span>
<span class="comment-syntax">onstant RELS_ASSERT_FALSE $0200;</span>
<span class="comment-syntax">onstant RELS_SHOW $0100;</span>
<span class="comment-syntax">onstant RELS_ROUTE_FIND $0080;</span>
<span class="comment-syntax">onstant RELS_ROUTE_FIND_COUNT $0040;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RELS_COPY</span><span class="plain-syntax"> </span><span class="constant-syntax">$0020</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RELS_DESTROY</span><span class="plain-syntax"> </span><span class="constant-syntax">$0010</span><span class="plain-syntax">;</span>
<span class="comment-syntax">onstant RELS_LOOKUP_ANY $0008;</span>
<span class="comment-syntax">onstant RELS_LOOKUP_ALL_X $0004;</span>
<span class="comment-syntax">onstant RELS_LOOKUP_ALL_Y $0002;</span>
<span class="comment-syntax">onstant RELS_LIST $0001;</span>

<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RELS_EMPTY</span><span class="plain-syntax"> </span><span class="constant-syntax">$0003</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RELS_SET_VALENCY</span><span class="plain-syntax"> </span><span class="constant-syntax">$0005</span><span class="plain-syntax">;</span>

<span class="comment-syntax">RELS_LOOKUP_ANY mode selection constants</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RLANY_GET_X</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RLANY_GET_Y</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RLANY_CAN_GET_X</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RLANY_CAN_GET_Y</span><span class="plain-syntax"> </span><span class="constant-syntax">4</span><span class="plain-syntax">;</span>

<span class="comment-syntax">RELS_LIST mode selection constant</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RLIST_ALL_X</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RLIST_ALL_Y</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RLIST_ALL_PAIRS</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax">;</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. Tunable Parameters.</b>These constants affect the performance characteristics of the dictionary
structures used for relations on the heap. Changing their values may alter the
balance between memory consumption and running time.
</p>

<p class="commentary"><span class="extract"><span class="extract-syntax">RRP_MIN_SIZE</span></span>, <span class="extract"><span class="extract-syntax">RRP_RESIZE_SMALL</span></span>, and <span class="extract"><span class="extract-syntax">RRP_RESIZE_LARGE</span></span> must all be
powers of two.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRP_MIN_SIZE</span><span class="plain-syntax">      </span><span class="constant-syntax">8</span><span class="plain-syntax">;   </span><span class="comment-syntax">minimum number of entries (DO NOT CHANGE)</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRP_PERTURB_SHIFT</span><span class="plain-syntax"> </span><span class="constant-syntax">5</span><span class="plain-syntax">;   </span><span class="comment-syntax">affects the probe sequence</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">MINUS_RRP_PERTURB_SHIFT</span><span class="plain-syntax"> -5;   </span><span class="comment-syntax">affects the probe sequence</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRP_RESIZE_SMALL</span><span class="plain-syntax">  </span><span class="constant-syntax">4</span><span class="plain-syntax">;   </span><span class="comment-syntax">resize factor for small tables</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRP_RESIZE_LARGE</span><span class="plain-syntax">  </span><span class="constant-syntax">2</span><span class="plain-syntax">;   </span><span class="comment-syntax">resize factor for large tables</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRP_LARGE_IS</span><span class="plain-syntax">      </span><span class="constant-syntax">256</span><span class="plain-syntax">; </span><span class="comment-syntax">how many entries make a table "large"?</span>
<span class="reserved-syntax">Constant</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRP_CROWDED_IS</span><span class="plain-syntax">    </span><span class="constant-syntax">2</span><span class="plain-syntax">;   </span><span class="comment-syntax">when filled entries outnumber unfilled by _ to 1</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Abstract Relations.</b>As the following shows, we can abstractly use a relation &mdash; that is, we can
use a relation whose identity we know little about &mdash; by calling its handler
routine <span class="extract"><span class="extract-syntax">R</span></span> in the form <span class="extract"><span class="extract-syntax">R(rel, task, X, Y)</span></span>.
</p>

<p class="commentary">The task should be one of: <span class="extract"><span class="extract-syntax">RELS_TEST</span></span>, <span class="extract"><span class="extract-syntax">RELS_ASSERT_TRUE</span></span>, <span class="extract"><span class="extract-syntax">RELS_ASSERT_FALSE</span></span>,
<span class="extract"><span class="extract-syntax">RELS_SHOW</span></span>, <span class="extract"><span class="extract-syntax">RELS_ROUTE_FIND</span></span>, <span class="extract"><span class="extract-syntax">RELS_ROUTE_FIND_COUNT</span></span>, <span class="extract"><span class="extract-syntax">RELS_COPY</span></span>,
<span class="extract"><span class="extract-syntax">RELS_DESTROY</span></span>, <span class="extract"><span class="extract-syntax">RELS_LOOKUP_ANY</span></span>, <span class="extract"><span class="extract-syntax">RELS_LOOKUP_ALL_X</span></span>, <span class="extract"><span class="extract-syntax">RELS_LOOKUP_ALL_Y</span></span>,
<span class="extract"><span class="extract-syntax">RELS_LIST</span></span>, or <span class="extract"><span class="extract-syntax">RELS_EMPTY</span></span>.
</p>

<p class="commentary"><span class="extract"><span class="extract-syntax">RELS_SHOW</span></span> produces output for the SHOWME testing command.
<span class="extract"><span class="extract-syntax">RELS_ROUTE_FIND</span></span> finds the next step in a route from <span class="extract"><span class="extract-syntax">X</span></span> to <span class="extract"><span class="extract-syntax">Y</span></span>, and
<span class="extract"><span class="extract-syntax">RELS_ROUTE_FIND_COUNT</span></span> counts the shortest number of steps or returns \(-1\)
if no route exists. <span class="extract"><span class="extract-syntax">RELS_COPY</span></span> makes a deep copy of the relation by
replacing all block values with duplicates, and <span class="extract"><span class="extract-syntax">RELS_DESTROY</span></span> frees all
block values. <span class="extract"><span class="extract-syntax">RELS_LOOKUP_ANY</span></span> finds any one of the <span class="extract"><span class="extract-syntax">X</span></span> values related to
a given <span class="extract"><span class="extract-syntax">Y</span></span>, or vice versa, or checks whether such an <span class="extract"><span class="extract-syntax">X</span></span> or <span class="extract"><span class="extract-syntax">Y</span></span> value
exists. <span class="extract"><span class="extract-syntax">RELS_LOOKUP_ALL_X</span></span> and <span class="extract"><span class="extract-syntax">RELS_LOOKUP_ALL_Y</span></span> produce a list of all
the <span class="extract"><span class="extract-syntax">X</span></span> values related to a given <span class="extract"><span class="extract-syntax">Y</span></span>, or vice versa. <span class="extract"><span class="extract-syntax">RELS_LIST</span></span> produces
a list of all <span class="extract"><span class="extract-syntax">X</span></span> values for which a corresponding <span class="extract"><span class="extract-syntax">Y</span></span> exists, or vice
versa, or a list of all <span class="extract"><span class="extract-syntax">(X,Y)</span></span> pairs for which <span class="extract"><span class="extract-syntax">X</span></span> is related to <span class="extract"><span class="extract-syntax">Y</span></span>.
<span class="extract"><span class="extract-syntax">RELS_EMPTY</span></span> either makes the relation empty (if <span class="extract"><span class="extract-syntax">X</span></span> is 1) or non-empty (if
<span class="extract"><span class="extract-syntax">X</span></span> is 0) or makes no change (if <span class="extract"><span class="extract-syntax">X</span></span> is negative), and in any case returns
true or false indicating whether the relation is now empty.
</p>

<p class="commentary">Because not every relation supports all of these operations, the
"permissions" word in the block is always a bitmap which is a sum of those
operations it does offer.
</p>

<p class="commentary">At present, these permissions are not checked as rigorously as they should be
(they're correctly set, but not much monitored).
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">RelationTest</span><span class="plain-syntax"> </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">task</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">  </span><span class="identifier-syntax">handler</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">handler</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RlnGetF</span><span class="plain-syntax">(</span><span class="identifier-syntax">relation</span><span class="plain-syntax">, </span><span class="identifier-syntax">RR_HANDLER</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">handler</span><span class="plain-syntax">(</span><span class="identifier-syntax">relation</span><span class="plain-syntax">, </span><span class="identifier-syntax">task</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">RlnGetF</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">fld</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> = </span><span class="identifier-syntax">BlkValueGetLongBlock</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">fld</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">RlnSetF</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">fld</span><span class="plain-syntax"> </span><span class="identifier-syntax">v</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> = </span><span class="identifier-syntax">BlkValueGetLongBlock</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">rel</span><span class="plain-syntax">--&gt;</span><span class="identifier-syntax">fld</span><span class="plain-syntax"> = </span><span class="identifier-syntax">v</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. Empty Relations.</b>The absolute minimum relation is one which can only be tested, and which is
always empty, that is, where no two values are ever related to each other.
The necessary handler routine is <span class="extract"><span class="extract-syntax">EmptyRelationHandler</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">EmptyRelationHandler</span><span class="plain-syntax"> </span><span class="identifier-syntax">relation</span><span class="plain-syntax"> </span><span class="identifier-syntax">task</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_EMPTY</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. Creation.</b>Something we have to be careful about is what we mean by copying, or indeed
creating, a relation. For example, if we write
</p>

<blockquote>
    <p>let Q be a relation of objects to objects;</p>
</blockquote>

<blockquote>
    <p>let Q be the containment relation;</p>
</blockquote>

<p class="commentary">...we aren't literally asking for Q to be a duplicate copy of containment,
which can then independently evolve &mdash; we mean in some sense that Q is a
pointer to the one and only containment relation. On the other hand, if we
write
</p>

<blockquote>
    <p>let Q be a relation of numbers to numbers;</p>
</blockquote>

<blockquote>
    <p>make Q relate 3 to 7;</p>
</blockquote>

<p class="commentary">then the second line clearly expects Q to be its own relation, newly created.
</p>

<p class="commentary">We cope with this at creation time. If we're invited to create a copy of an
existing relation, we look to see if it is empty &mdash; which we detect by its
use of the <span class="extract"><span class="extract-syntax">EmptyRelationHandler</span></span> handler. The empty relations are exactly
those used as default values for the relation kinds; thus that's what will
happen when Q is created. If we find this handler, we intercept and replace
it with one of the heap relation handlers, which thus makes the relation a
newly constructed data structure which can grow freely from here.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">RELATION_TY_Create</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> </span><span class="identifier-syntax">sb_address</span><span class="plain-syntax"> </span><span class="identifier-syntax">from</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">short_block</span><span class="plain-syntax"> </span><span class="identifier-syntax">long_block</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">handler</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">long_block</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CreatePVLongBlockFlexible</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">RRP_MIN_SIZE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">from</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">)) </span><span class="identifier-syntax">from</span><span class="plain-syntax"> = </span><span class="identifier-syntax">DefaultValueFinder</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">from</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax">: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">from</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">from</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_HANDLER</span><span class="plain-syntax">) == </span><span class="identifier-syntax">EmptyRelationHandler</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">handler</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ChooseRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">PVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_KIND</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_NAME</span><span class="plain-syntax">, </span><span class="string-syntax">"anonymous relation"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_PERMISSIONS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">RELS_TEST</span><span class="plain-syntax">+</span><span class="identifier-syntax">RELS_ASSERT_TRUE</span><span class="plain-syntax">+</span><span class="identifier-syntax">RELS_ASSERT_FALSE</span><span class="plain-syntax">+</span><span class="identifier-syntax">RELS_SHOW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_HANDLER</span><span class="plain-syntax">, </span><span class="identifier-syntax">handler</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRP_MIN_SIZE</span><span class="plain-syntax">-1);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DESCRIPTION</span><span class="plain-syntax">, </span><span class="string-syntax">"an anonymous relation"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">handler</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ChooseRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_NAME</span><span class="plain-syntax">, </span><span class="string-syntax">"anonymous relation"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_PERMISSIONS</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">RELS_TEST</span><span class="plain-syntax">+</span><span class="identifier-syntax">RELS_ASSERT_TRUE</span><span class="plain-syntax">+</span><span class="identifier-syntax">RELS_ASSERT_FALSE</span><span class="plain-syntax">+</span><span class="identifier-syntax">RELS_SHOW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRP_MIN_SIZE</span><span class="plain-syntax">-1);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_KIND</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_HANDLER</span><span class="plain-syntax">, </span><span class="identifier-syntax">handler</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DESCRIPTION</span><span class="plain-syntax">, </span><span class="string-syntax">"an anonymous relation"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">long_block</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>

<span class="plain-syntax">    </span><span class="identifier-syntax">short_block</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CreatePVShortBlock</span><span class="plain-syntax">(</span><span class="identifier-syntax">sb_address</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">short_block</span><span class="plain-syntax">--&gt;0 = </span><span class="identifier-syntax">long_block</span><span class="plain-syntax">;</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">short_block</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. Extent.</b>We need to provide an explicit function for this, even though we only say the
answer is "use the capacity".
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">RELATION_TY_LongBlockSize</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. Destruction.</b>If the relation stores block values on either side, invoke the handler using a special task
value to free the memory associated with them.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">RELATION_TY_Destroy</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax">  </span><span class="identifier-syntax">handler</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">handler</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_HANDLER</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">handler</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RELS_DESTROY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. Copying.</b>Same as destruction: invoke the handler using a special value to tell it to perform
deep copying.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">RELATION_TY_Copy</span><span class="plain-syntax"> </span><span class="identifier-syntax">lto</span><span class="plain-syntax"> </span><span class="identifier-syntax">lfrom</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> </span><span class="identifier-syntax">recycling</span><span class="plain-syntax">  </span><span class="identifier-syntax">handler</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CopyPVRawData</span><span class="plain-syntax">(</span><span class="identifier-syntax">lto</span><span class="plain-syntax">, </span><span class="identifier-syntax">lfrom</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax">, </span><span class="identifier-syntax">recycling</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">handler</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">lto</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_HANDLER</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">handler</span><span class="plain-syntax">(</span><span class="identifier-syntax">lto</span><span class="plain-syntax">, </span><span class="identifier-syntax">RELS_COPY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. Comparison.</b>It really isn't clear how to define equality for relations, but we follow
the doctrine above. What we don't do is to test its actual state &mdash; that
would be very slow and might be impossible.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">RELATION_TY_Compare</span><span class="plain-syntax"> </span><span class="identifier-syntax">rleft</span><span class="plain-syntax"> </span><span class="identifier-syntax">rright</span><span class="plain-syntax"> </span><span class="identifier-syntax">ind1</span><span class="plain-syntax"> </span><span class="identifier-syntax">ind2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ind1</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rleft</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_HANDLER</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ind2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rright</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_HANDLER</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ind1</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">ind2</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">ind1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">ind2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">IsMutableRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">ind1</span><span class="plain-syntax">) == </span><span class="reserved-syntax">false</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">rleft</span><span class="plain-syntax"> - </span><span class="identifier-syntax">rright</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">RELATION_TY_Distinguish</span><span class="plain-syntax"> </span><span class="identifier-syntax">rleft</span><span class="plain-syntax"> </span><span class="identifier-syntax">rright</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">RELATION_TY_Compare</span><span class="plain-syntax">(</span><span class="identifier-syntax">rleft</span><span class="plain-syntax">, </span><span class="identifier-syntax">rright</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. Printing.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">RELATION_TY_Say</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rel</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"(null relation)"</span><span class="plain-syntax">; </span><span class="comment-syntax">shouldn't happen</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">print</span><span class="plain-syntax"> (</span><span class="reserved-syntax">string</span><span class="plain-syntax">) </span><span class="identifier-syntax">RlnGetF</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RR_NAME</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. Naming.</b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">RELATION_TY_Name</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">txt</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rel</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_NAME</span><span class="plain-syntax">, </span><span class="identifier-syntax">txt</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DESCRIPTION</span><span class="plain-syntax">, </span><span class="identifier-syntax">txt</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. Choose Relation Handler.</b>We implement two different various-to-various handler routines for the
sake of efficiency. The choice of handler routines is made based on
the kinds of value being related. Each handler also has a corresponding
wrapper for symmetric relations.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">ChooseRelationHandler</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> </span><span class="identifier-syntax">sym</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sym</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">SymHashListRelationHandler</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">HashListRelationHandler</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sym</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">SymDoubleHashSetRelationHandler</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">DoubleHashSetRelationHandler</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">IsMutableRelationHandler</span><span class="plain-syntax"> </span><span class="identifier-syntax">h</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">h</span><span class="plain-syntax"> == </span><span class="identifier-syntax">SymHashListRelationHandler</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">HashListRelationHandler</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SymDoubleHashSetRelationHandler</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">DoubleHashSetRelationHandler</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. Valency.</b>"Valency" refers to the number of participants allowed on either side
of the relation: various-to-various, one-to-various, various-to-one, or
one-to-one. A newly created relation is always various-to-various. We
allow the author to change the valency, but only if no entries have
been added yet.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">RELATION_TY_SetValency</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">val</span><span class="plain-syntax">  </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> </span><span class="identifier-syntax">filled</span><span class="plain-syntax"> </span><span class="identifier-syntax">cur</span><span class="plain-syntax"> </span><span class="identifier-syntax">handler</span><span class="plain-syntax"> </span><span class="identifier-syntax">ext</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">filled</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">filled</span><span class="plain-syntax">) { </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"ChangedImmutableRelation"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"This change of the relation's nature is impossible in play."</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">BasicInformKitRTPs</span><span class="plain-syntax">); </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_KIND</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RRVAL_EQUIV</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRVAL_SYM_V_TO_V</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRVAL_SYM_O_TO_O</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"ChangedImmutableRelation"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"This change of the relation's nature is impossible in play."</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">BasicInformKitRTPs</span><span class="plain-syntax">); </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cur</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_HANDLER</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">val</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RRVAL_V_TO_V</span><span class="plain-syntax">:       </span><span class="identifier-syntax">handler</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ChooseRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="reserved-syntax">false</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RRVAL_V_TO_O</span><span class="plain-syntax">:       </span><span class="identifier-syntax">handler</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HashTableRelationHandler</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RRVAL_O_TO_V</span><span class="plain-syntax">:       </span><span class="identifier-syntax">handler</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ReversedHashTableRelationHandler</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RRVAL_O_TO_O</span><span class="plain-syntax">:       </span><span class="identifier-syntax">handler</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TwoInOneHashTableRelationHandler</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RRVAL_EQUIV</span><span class="plain-syntax">:        </span><span class="identifier-syntax">handler</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EquivHashTableRelationHandler</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RRVAL_SYM_V_TO_V</span><span class="plain-syntax">:   </span><span class="identifier-syntax">handler</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ChooseRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="reserved-syntax">true</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RRVAL_SYM_O_TO_O</span><span class="plain-syntax">:   </span><span class="identifier-syntax">handler</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Sym2in1HashTableRelationHandler</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">default</span><span class="plain-syntax">:            </span><span class="identifier-syntax">IssueRTP</span><span class="plain-syntax">(</span><span class="string-syntax">"ChangedImmutableRelation"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                                </span><span class="string-syntax">"This change of the relation's nature is impossible in play."</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                                </span><span class="identifier-syntax">BasicInformKitRTPs</span><span class="plain-syntax">); </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cur</span><span class="plain-syntax"> == </span><span class="identifier-syntax">handler</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="comment-syntax">adjust size when going to or from 2-in-1</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cur</span><span class="plain-syntax"> == </span><span class="identifier-syntax">TwoInOneHashTableRelationHandler</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SetPVFieldCapacity</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">ext</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">handler</span><span class="plain-syntax"> == </span><span class="identifier-syntax">TwoInOneHashTableRelationHandler</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SetPVFieldCapacity</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">ext</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_HANDLER</span><span class="plain-syntax">, </span><span class="identifier-syntax">handler</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">RELATION_TY_GetValency</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax">  </span><span class="identifier-syntax">handler</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_PERMISSIONS</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">VALENCY_MASK</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. Double Hash Set Relation Handler.</b>This implements relations which are stored as a double-hashed set.
The storage comprises a list of three-word entries \((F, X, Y)\), where
\(F\) is a flags word. The ordering of the list is determined by a probe
sequence which depends on the combined hash values of \(X\) and \(Y\).
</p>

<p class="commentary">The "storage" word in the header stores one less than the number of
entries in the list; the number of entries in the list is always a
power of two, so this will always be a bit mask. The "used" and
"filled" words store the number of entries which currently hold a
value, and the number of entries which have ever held a value (even
if it was since deleted), respectively.
</p>

<p class="commentary">The utility routine <span class="extract"><span class="extract-syntax">DoubleHashSetLookUp</span></span> locates the hash entry for
a key/value pair. It returns either the (non-negative) number of the
entry where the pair was found, or the (negative) bitwise NOT of the
number of the first unused entry where the pair could be inserted. It
uses the utility routine <span class="extract"><span class="extract-syntax">DoubleHashSetEntryMatches</span></span> to compare
entries to the sought pair.
</p>

<p class="commentary">The utility routine <span class="extract"><span class="extract-syntax">DoubleHashSetCheckResize</span></span> checks whether the
dictionary has become too full after inserting a pair, and expands it
if so.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">DoubleHashSetRelationHandler</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">task</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> </span><span class="identifier-syntax">sym</span><span class="plain-syntax">  </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> </span><span class="identifier-syntax">v</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_KIND</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">); </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_SET_VALENCY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">RELATION_TY_SetValency</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_DESTROY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="comment-syntax">clear</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">); </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">kx</span><span class="plain-syntax"> || </span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">kx</span><span class="plain-syntax">) </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ky</span><span class="plain-syntax">) </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_COPY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">); </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">X</span><span class="plain-syntax"> || </span><span class="identifier-syntax">Y</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">), </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">), </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_SHOW</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> (</span><span class="reserved-syntax">string</span><span class="plain-syntax">) </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DESCRIPTION</span><span class="plain-syntax">), </span><span class="string-syntax">":^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sym</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindComparisonFunction</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">) </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> = </span><span class="identifier-syntax">UnsignedCompare</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sym</span><span class="plain-syntax"> &amp;&amp; (</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">)) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"  "</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sym</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">" &lt;=&gt; "</span><span class="plain-syntax">; </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">" &gt;=&gt; "</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_EMPTY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">DoubleHashSetRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RELS_DESTROY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_LOOKUP_ANY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RLANY_GET_X</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">RLANY_CAN_GET_X</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">v</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">v</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">) ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">v</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">X</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RLANY_CAN_GET_X</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">v</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">v</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">) ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">v</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">X</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RLANY_CAN_GET_Y</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RLANY_GET_X</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">RLANY_GET_Y</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Lookup failed: value not found ***^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_LOOKUP_ALL_X</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">WeakKindOfPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">LIST_OF_TY</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LIST_OF_TY_SetLength</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">v</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">v</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">) ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">v</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">X</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_LOOKUP_ALL_Y</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">WeakKindOfPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">LIST_OF_TY</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LIST_OF_TY_SetLength</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">v</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">v</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">) ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">v</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">X</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_LIST</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax"> || </span><span class="identifier-syntax">WeakKindOfPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">LIST_OF_TY</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LIST_OF_TY_SetLength</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">RLIST_ALL_X</span><span class="plain-syntax">, </span><span class="identifier-syntax">RLIST_ALL_Y</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RLIST_ALL_Y</span><span class="plain-syntax">) </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">v</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">v</span><span class="plain-syntax">, </span><span class="reserved-syntax">false</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="reserved-syntax">true</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">RLIST_ALL_PAIRS</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="comment-syntax">LIST_OF_TY_InsertItem will make a deep copy of the item,</span>
<span class="plain-syntax">                </span><span class="comment-syntax">so we can reuse a single combination value here</span>

<span class="plain-syntax">                </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">v</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">COMBINATION_ITEM_BASE</span><span class="plain-syntax">, </span><span class="identifier-syntax">v</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">v</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">COMBINATION_ITEM_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">v</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">COMBINATION_ITEM_BASE</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">COMBINATION_ITEM_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">DoubleHashSetLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax">(</span><span class="identifier-syntax">task</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_TEST</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_ASSERT_TRUE</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = ~</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">), </span><span class="identifier-syntax">X</span><span class="plain-syntax">); }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">), </span><span class="identifier-syntax">Y</span><span class="plain-syntax">); }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">DoubleHashSetCheckResize</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_ASSERT_FALSE</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">) - </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_DELETED</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">DoubleHashSetLookUp</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">  </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">free</span><span class="plain-syntax"> </span><span class="identifier-syntax">mask</span><span class="plain-syntax"> </span><span class="identifier-syntax">perturb</span><span class="plain-syntax"> </span><span class="identifier-syntax">flags</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="comment-syntax">calculate a hash value for the pair</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HashKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">) + </span><span class="identifier-syntax">HashKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="comment-syntax">look in the first expected slot</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">mask</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">mask</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">flags</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">flags</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">DoubleHashSetEntryMatches</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="comment-syntax">not here, keep looking in sequence</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">free</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">flags</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_DELETED</span><span class="plain-syntax">) </span><span class="identifier-syntax">free</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">perturb</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hashv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (::) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hashv</span><span class="plain-syntax">*5 + </span><span class="identifier-syntax">perturb</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">mask</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">flags</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">flags</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">free</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">free</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">DoubleHashSetEntryMatches</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">))</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">free</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">flags</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_DELETED</span><span class="plain-syntax">)) </span><span class="identifier-syntax">free</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">ifdef</span><span class="plain-syntax"> </span><span class="identifier-syntax">TARGET_ZCODE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">log_shift</span><span class="plain-syntax"> </span><span class="identifier-syntax">perturb</span><span class="plain-syntax"> </span><span class="identifier-syntax">MINUS_RRP_PERTURB_SHIFT</span><span class="plain-syntax"> -&gt; </span><span class="identifier-syntax">perturb</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">ifnot</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">ushiftr</span><span class="plain-syntax"> </span><span class="identifier-syntax">perturb</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRP_PERTURB_SHIFT</span><span class="plain-syntax"> </span><span class="identifier-syntax">perturb</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">endif</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">DoubleHashSetCheckResize</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax">  </span><span class="identifier-syntax">filled</span><span class="plain-syntax"> </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> </span><span class="identifier-syntax">newext</span><span class="plain-syntax"> </span><span class="identifier-syntax">temp</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">filled</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">filled</span><span class="plain-syntax"> &gt;= (</span><span class="identifier-syntax">ext</span><span class="plain-syntax"> - </span><span class="identifier-syntax">filled</span><span class="plain-syntax">) * </span><span class="identifier-syntax">RRP_CROWDED_IS</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="comment-syntax">copy entries to temporary space</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">temp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FlexAllocate</span><span class="plain-syntax">(</span><span class="identifier-syntax">ext</span><span class="plain-syntax"> * (3*</span><span class="identifier-syntax">WORDSIZE</span><span class="plain-syntax">), </span><span class="identifier-syntax">TEXT_TY</span><span class="plain-syntax">, </span><span class="identifier-syntax">BLK_FLAG_WORD</span><span class="plain-syntax">+</span><span class="identifier-syntax">BLK_FLAG_MULTIPLE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">ext</span><span class="plain-syntax">*3: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax">+</span><span class="identifier-syntax">i</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="comment-syntax">resize and clear our data</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ext</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">RRP_LARGE_IS</span><span class="plain-syntax">) </span><span class="identifier-syntax">newext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> * </span><span class="identifier-syntax">RRP_RESIZE_LARGE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">newext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> * </span><span class="identifier-syntax">RRP_RESIZE_SMALL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SetPVFieldCapacity</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="identifier-syntax">newext</span><span class="plain-syntax">*3);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">, </span><span class="identifier-syntax">newext</span><span class="plain-syntax"> - </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">newext</span><span class="plain-syntax">*3: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax">+</span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="comment-syntax">copy entries back from temporary space</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_KIND</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">); </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">ext</span><span class="plain-syntax">: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">F</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax"> || (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_DELETED</span><span class="plain-syntax">)) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">DoubleHashSetLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) { </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Duplicate entry while resizing ***^"</span><span class="plain-syntax">; </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = ~</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">F</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="comment-syntax">done with temporary space</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">FlexFree</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">DoubleHashSetEntryMatches</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">  </span><span class="identifier-syntax">cx</span><span class="plain-syntax"> </span><span class="identifier-syntax">cy</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cx</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">cx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">) ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cx</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">X</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cy</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">cy</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cy</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP16" class="paragraph-anchor"></a><b>&#167;16. Hash List Relation Handler.</b>This implements relations which are stored as a hash table mapping
keys to either single values or lists of values. The storage comprises a list
of three-word entries, either \((F, X, Y)\) or \((F, X, L)\), where \(F\) is a
flags word distinguishing between the two cases (among other things). In the
latter case, \(L\) is a pointer to a list (<span class="extract"><span class="extract-syntax">LIST_OF_TY</span></span>) containing the values.
</p>

<p class="commentary">The "storage", "used", and "filled" words have the same meanings as
above.
</p>

<p class="commentary"><span class="extract"><span class="extract-syntax">HashListRelationHandler</span></span> is a thin wrapper around <span class="extract"><span class="extract-syntax">HashCoreRelationHandler</span></span>,
which is shared with two other handlers below.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">HashListRelationHandler</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">task</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">  </span><span class="identifier-syntax">sym</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> </span><span class="identifier-syntax">ky</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_KIND</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">); </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">HashCoreRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">task</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP17" class="paragraph-anchor"></a><b>&#167;17. Hash Table Relation Handler.</b>This is the same as the Hash List Relation Handler above, except that only
one value may be stored for each key. This implements various-to-one
relations.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">HashTableRelationHandler</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">task</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">  </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> </span><span class="identifier-syntax">ky</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_KIND</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">); </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">HashCoreRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">task</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP18" class="paragraph-anchor"></a><b>&#167;18. Reversed Hash Table Relation Handler.</b>This is the same as the Hash Table Relation Handler except that the sides
are reversed. This implements one-to-various relations.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">ReversedHashTableRelationHandler</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">task</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">  </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> </span><span class="identifier-syntax">swap</span><span class="plain-syntax">;</span>
<span class="comment-syntax">print "ReversedHashTableRelationHandler ", rel, " ", task, " X=", X, " Y=", Y, "^";</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_KIND</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">); </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_SET_VALENCY</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">RELATION_TY_SetValency</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_TEST</span><span class="plain-syntax">, </span><span class="identifier-syntax">RELS_ASSERT_TRUE</span><span class="plain-syntax">, </span><span class="identifier-syntax">RELS_ASSERT_FALSE</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">HashCoreRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">task</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_LOOKUP_ANY</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">RLANY_GET_X</span><span class="plain-syntax">: </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RLANY_GET_Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">RLANY_GET_Y</span><span class="plain-syntax">: </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RLANY_GET_X</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">RLANY_CAN_GET_X</span><span class="plain-syntax">: </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RLANY_CAN_GET_Y</span><span class="plain-syntax">; </span><span class="identifier-syntax">swap</span><span class="plain-syntax">=</span><span class="identifier-syntax">kx</span><span class="plain-syntax">; </span><span class="identifier-syntax">kx</span><span class="plain-syntax">=</span><span class="identifier-syntax">ky</span><span class="plain-syntax">; </span><span class="identifier-syntax">ky</span><span class="plain-syntax">=</span><span class="identifier-syntax">swap</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">RLANY_CAN_GET_Y</span><span class="plain-syntax">: </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RLANY_CAN_GET_X</span><span class="plain-syntax">; </span><span class="identifier-syntax">swap</span><span class="plain-syntax">=</span><span class="identifier-syntax">kx</span><span class="plain-syntax">; </span><span class="identifier-syntax">kx</span><span class="plain-syntax">=</span><span class="identifier-syntax">ky</span><span class="plain-syntax">; </span><span class="identifier-syntax">ky</span><span class="plain-syntax">=</span><span class="identifier-syntax">swap</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_LOOKUP_ALL_X</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">task</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RELS_LOOKUP_ALL_Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_LOOKUP_ALL_Y</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">task</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RELS_LOOKUP_ALL_X</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_SHOW</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">swap</span><span class="plain-syntax">=</span><span class="identifier-syntax">X</span><span class="plain-syntax">; </span><span class="identifier-syntax">X</span><span class="plain-syntax">=</span><span class="identifier-syntax">Y</span><span class="plain-syntax">; </span><span class="identifier-syntax">Y</span><span class="plain-syntax">=</span><span class="identifier-syntax">swap</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">swap</span><span class="plain-syntax">=</span><span class="identifier-syntax">kx</span><span class="plain-syntax">; </span><span class="identifier-syntax">kx</span><span class="plain-syntax">=</span><span class="identifier-syntax">ky</span><span class="plain-syntax">; </span><span class="identifier-syntax">ky</span><span class="plain-syntax">=</span><span class="identifier-syntax">swap</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_LIST</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">RLIST_ALL_X</span><span class="plain-syntax">: </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RLIST_ALL_Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">RLIST_ALL_Y</span><span class="plain-syntax">: </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RLIST_ALL_X</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">HashCoreRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">task</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP19" class="paragraph-anchor"></a><b>&#167;19. Symmetric Relation Handlers.</b>These are simple wrappers around the asymmetric handlers defined above.
When a pair is inserted or removed, the wrappers insert or remove the
reversed pair as well.
</p>

<p class="commentary"><span class="extract"><span class="extract-syntax">SymDoubleHashSetRelationHandler</span></span> and <span class="extract"><span class="extract-syntax">SymHashListRelationHandler</span></span>
implement symmetric V-to-V relations.
<span class="extract"><span class="extract-syntax">Sym2in1HashTableRelationHandler</span></span> implements symmetric 1-to-1.
("<span class="extract"><span class="extract-syntax">SymTwoInOneHashTableRelationHandler</span></span>" would have
exceeded Inform 6's 32-character name limit.)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">SymDoubleHashSetRelationHandler</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">task</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_ASSERT_TRUE</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">RELS_ASSERT_FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">DoubleHashSetRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">task</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">DoubleHashSetRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">task</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">SymHashListRelationHandler</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">task</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_ASSERT_TRUE</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">RELS_ASSERT_FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">HashListRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">task</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">HashListRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">task</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">Sym2in1HashTableRelationHandler</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">task</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_ASSERT_TRUE</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">RELS_ASSERT_FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">TwoInOneHashTableRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">task</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">TwoInOneHashTableRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">task</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP20" class="paragraph-anchor"></a><b>&#167;20. Hash Core Relation Handler.</b>This implements the core functionality that is shared between
<span class="extract"><span class="extract-syntax">HashListRelationHandler</span></span>, <span class="extract"><span class="extract-syntax">HashTableRelationHandler</span></span>, and
<span class="extract"><span class="extract-syntax">ReversedHashTableRelationHandler</span></span>. All three handlers are the same except
for whether the left or right side is the "key" and whether or not
multiple values may be stored for a single key.
</p>

<p class="commentary">As noted above, the table contains three-word entries, \((F, X, Y)\),
where \(F\) is a flags word. Only the hash code of \(X\) is used. If \(F\)
includes <span class="extract"><span class="extract-syntax">RRF_SINGLE</span></span>, \(Y\) is a single value; otherwise, \(Y\) is a list
(<span class="extract"><span class="extract-syntax">LIST_OF_TY</span></span>) of values. If <span class="extract"><span class="extract-syntax">mult</span></span> is zero, <span class="extract"><span class="extract-syntax">RRF_SINGLE</span></span> must always be
set, allowing only one value per key: a new pair \((X, Y')\) will replace
the existing pair \((X, Y)\).
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">HashCoreRelationHandler</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">task</span><span class="plain-syntax"> </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> </span><span class="identifier-syntax">mult</span><span class="plain-syntax">  </span><span class="identifier-syntax">sym</span><span class="plain-syntax"> </span><span class="identifier-syntax">rev</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> </span><span class="identifier-syntax">fl</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_SET_VALENCY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">RELATION_TY_SetValency</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_DESTROY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="comment-syntax">clear</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">); </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">kx</span><span class="plain-syntax"> || </span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">kx</span><span class="plain-syntax">) </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ky</span><span class="plain-syntax"> || ~~(</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_COPY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">); </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">X</span><span class="plain-syntax"> || </span><span class="identifier-syntax">Y</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">), </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> || ~~(</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">WeakKindOfPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">)), </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_SHOW</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> (</span><span class="reserved-syntax">string</span><span class="plain-syntax">) </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DESCRIPTION</span><span class="plain-syntax">), </span><span class="string-syntax">":^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="comment-syntax">Z-machine doesn't have the room to let us pass sym/rev as parameters</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">RELATION_TY_GetValency</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">RRVAL_SYM_V_TO_V</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">sym</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindComparisonFunction</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">UnsignedCompare</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">RRVAL_O_TO_V</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">rev</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sym</span><span class="plain-syntax"> &amp;&amp; </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"  "</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rev</span><span class="plain-syntax">) </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sym</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">" &lt;=&gt; "</span><span class="plain-syntax">; </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">" &gt;=&gt; "</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rev</span><span class="plain-syntax">) </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">mult</span><span class="plain-syntax">=1: </span><span class="identifier-syntax">mult</span><span class="plain-syntax">&lt;=</span><span class="identifier-syntax">LIST_OF_TY_GetLength</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">): </span><span class="identifier-syntax">mult</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">LIST_OF_TY_GetItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">mult</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sym</span><span class="plain-syntax"> &amp;&amp; </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">fl</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"  "</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rev</span><span class="plain-syntax">) </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">fl</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sym</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">" &lt;=&gt; "</span><span class="plain-syntax">; </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">" &gt;=&gt; "</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">rev</span><span class="plain-syntax">) </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">fl</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_EMPTY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">HashCoreRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RELS_DESTROY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_LOOKUP_ANY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RLANY_GET_Y</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">RLANY_CAN_GET_Y</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HashCoreLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RLANY_CAN_GET_Y</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">LIST_OF_TY_GetItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">sym</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">sym</span><span class="plain-syntax">) ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">sym</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        }</span>
<span class="plain-syntax">                    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">LIST_OF_TY_FindItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">sym</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RLANY_CAN_GET_X</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RLANY_GET_X</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">RLANY_GET_Y</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Lookup failed: value not found ***^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_LOOKUP_ALL_X</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">WeakKindOfPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">LIST_OF_TY</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LIST_OF_TY_SetLength</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">sym</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">sym</span><span class="plain-syntax">) ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">sym</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">LIST_OF_TY_FindItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">sym</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_LOOKUP_ALL_Y</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">WeakKindOfPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">LIST_OF_TY</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LIST_OF_TY_SetLength</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HashCoreLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LIST_OF_TY_AppendList</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_LIST</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">WeakKindOfPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">LIST_OF_TY</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LIST_OF_TY_SetLength</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">RLIST_ALL_X</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">RLIST_ALL_Y</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                            </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="reserved-syntax">false</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="reserved-syntax">true</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">                            </span><span class="identifier-syntax">LIST_OF_TY_AppendList</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="reserved-syntax">false</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="reserved-syntax">true</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">RLIST_ALL_PAIRS</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">RELATION_TY_GetValency</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">) == </span><span class="identifier-syntax">RRVAL_O_TO_V</span><span class="plain-syntax">) </span><span class="identifier-syntax">rev</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="comment-syntax">LIST_OF_TY_InsertItem will make a deep copy of the item,</span>
<span class="plain-syntax">                </span><span class="comment-syntax">so we can reuse a single combination value here</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">COMBINATION_TY</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">COMBINATION_ITEM_BASE</span><span class="plain-syntax"> + </span><span class="identifier-syntax">rev</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">COMBINATION_ITEM_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">rev</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                            </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                            </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">mult</span><span class="plain-syntax"> = </span><span class="identifier-syntax">LIST_OF_TY_GetLength</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">): </span><span class="identifier-syntax">mult</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">mult</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">                                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">COMBINATION_ITEM_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax"> - </span><span class="identifier-syntax">rev</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                                    </span><span class="identifier-syntax">LIST_OF_TY_GetItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="identifier-syntax">mult</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                                </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                            }</span>
<span class="plain-syntax">                        }</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">COMBINATION_ITEM_BASE</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">COMBINATION_ITEM_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HashCoreLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax">(</span><span class="identifier-syntax">task</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_TEST</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">LIST_OF_TY_FindItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_ASSERT_TRUE</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="comment-syntax">no entry exists for this key, just add one</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = ~</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">), </span><span class="identifier-syntax">X</span><span class="plain-syntax">); }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">), </span><span class="identifier-syntax">Y</span><span class="plain-syntax">); }</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">HashCoreCheckResize</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="comment-syntax">an entry exists: could be a list or a single value</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);        </span><span class="comment-syntax">flags</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);   </span><span class="comment-syntax">value or list</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="comment-syntax">if Y is the same as the stored key, we have nothing to do</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="comment-syntax">it's different: either replace it or expand into a list,</span>
<span class="plain-syntax">                </span><span class="comment-syntax">depending on the value of mult</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">mult</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">LIST_OF_TY</span><span class="plain-syntax">);  </span><span class="comment-syntax">new list</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">fl</span><span class="plain-syntax">, </span><span class="identifier-syntax">LIST_ITEM_KOV_F</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">LIST_OF_TY_SetLength</span><span class="plain-syntax">(</span><span class="identifier-syntax">fl</span><span class="plain-syntax">, </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">fl</span><span class="plain-syntax">, </span><span class="identifier-syntax">LIST_ITEM_BASE</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);  </span><span class="comment-syntax">do not copy</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">LIST_OF_TY_PutItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">fl</span><span class="plain-syntax">, </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);       </span><span class="comment-syntax">copy if needed</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">fl</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">), </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="comment-syntax">if Y is present already, do nothing. otherwise add it.</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_ASSERT_FALSE</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="comment-syntax">an entry exists: could be a list or a single value</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);        </span><span class="comment-syntax">flags</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);   </span><span class="comment-syntax">value or list</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="comment-syntax">if the stored key isn't Y, we have nothing to do</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="comment-syntax">delete the entry</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                .</span><span class="identifier-syntax">DeleteEntryIgnoringY</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">) - </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_DELETED</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="comment-syntax">remove Y from the list if present</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LIST_OF_TY_RemoveValue</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="comment-syntax">if the list is now empty, delete the whole entry</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">LIST_OF_TY_GetLength</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">jump</span><span class="plain-syntax"> </span><span class="identifier-syntax">DeleteEntryIgnoringY</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">HashCoreLookUp</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax">  </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">free</span><span class="plain-syntax"> </span><span class="identifier-syntax">mask</span><span class="plain-syntax"> </span><span class="identifier-syntax">perturb</span><span class="plain-syntax"> </span><span class="identifier-syntax">flags</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="comment-syntax">calculate a hash value for the key</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HashKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="comment-syntax">look in the first expected slot</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">mask</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">mask</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">flags</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">flags</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">HashCoreEntryMatches</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="comment-syntax">not here, keep looking in sequence</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">free</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">flags</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_DELETED</span><span class="plain-syntax">) </span><span class="identifier-syntax">free</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">perturb</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hashv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (::) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hashv</span><span class="plain-syntax">*5 + </span><span class="identifier-syntax">perturb</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">mask</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">flags</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">flags</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">free</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">free</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">HashCoreEntryMatches</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">free</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">flags</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_DELETED</span><span class="plain-syntax">)) </span><span class="identifier-syntax">free</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">ifdef</span><span class="plain-syntax"> </span><span class="identifier-syntax">TARGET_ZCODE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">log_shift</span><span class="plain-syntax"> </span><span class="identifier-syntax">perturb</span><span class="plain-syntax"> </span><span class="identifier-syntax">MINUS_RRP_PERTURB_SHIFT</span><span class="plain-syntax"> -&gt; </span><span class="identifier-syntax">perturb</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">ifnot</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">ushiftr</span><span class="plain-syntax"> </span><span class="identifier-syntax">perturb</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRP_PERTURB_SHIFT</span><span class="plain-syntax"> </span><span class="identifier-syntax">perturb</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">endif</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">HashCoreCheckResize</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax">  </span><span class="identifier-syntax">filled</span><span class="plain-syntax"> </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> </span><span class="identifier-syntax">newext</span><span class="plain-syntax"> </span><span class="identifier-syntax">temp</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">filled</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">filled</span><span class="plain-syntax"> &gt;= (</span><span class="identifier-syntax">ext</span><span class="plain-syntax"> - </span><span class="identifier-syntax">filled</span><span class="plain-syntax">) * </span><span class="identifier-syntax">RRP_CROWDED_IS</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="comment-syntax">copy entries to temporary space</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">temp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FlexAllocate</span><span class="plain-syntax">(</span><span class="identifier-syntax">ext</span><span class="plain-syntax"> * (3*</span><span class="identifier-syntax">WORDSIZE</span><span class="plain-syntax">), </span><span class="identifier-syntax">TEXT_TY</span><span class="plain-syntax">, </span><span class="identifier-syntax">BLK_FLAG_WORD</span><span class="plain-syntax">+</span><span class="identifier-syntax">BLK_FLAG_MULTIPLE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">ext</span><span class="plain-syntax">*3: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax">+</span><span class="identifier-syntax">i</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="comment-syntax">resize and clear our data</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ext</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">RRP_LARGE_IS</span><span class="plain-syntax">) </span><span class="identifier-syntax">newext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> * </span><span class="identifier-syntax">RRP_RESIZE_LARGE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">newext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> * </span><span class="identifier-syntax">RRP_RESIZE_SMALL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SetPVFieldCapacity</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="identifier-syntax">newext</span><span class="plain-syntax">*3);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">, </span><span class="identifier-syntax">newext</span><span class="plain-syntax"> - </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">newext</span><span class="plain-syntax">*3: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax">+</span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="comment-syntax">copy entries back from temporary space</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_KIND</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">); </span><span class="comment-syntax">Was 0</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">ext</span><span class="plain-syntax">: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">F</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax"> || (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_DELETED</span><span class="plain-syntax">)) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HashCoreLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) { </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Duplicate entry while resizing ***^"</span><span class="plain-syntax">; </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = ~</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">F</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="comment-syntax">done with temporary space</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">FlexFree</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">HashCoreEntryMatches</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax">  </span><span class="identifier-syntax">cx</span><span class="plain-syntax"> </span><span class="identifier-syntax">cy</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">cx</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">cx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">) ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">cx</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">X</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP21" class="paragraph-anchor"></a><b>&#167;21. Equivalence Hash Table Relation Handler.</b>This implements group relations. The table format is identical to that used
by <span class="extract"><span class="extract-syntax">HashCoreRelationHandler</span></span>, but we use it differently. Although the
relation appears to relate Xs to Xs as far as the game is concerned, the
table actually relates Xs to numbers, where each number identifies a
group of related items. Any X not listed in the table is implicitly in
a single-member group.
</p>

<p class="commentary">When a pair \((X, Y)\) is inserted, one of four cases occurs:
</p>

<p class="commentary">1. Neither \(X\) nor \(Y\) has a table entry. We search the table to find the
next unused group number, then add both \(X\) and \(Y\) to that group.
</p>

<p class="commentary">2. Both \(X\) and \(Y\) have existing table entries. If the group numbers
differ, we walk through the table and change all occurrences of the
higher number to the lower one.
</p>

<p class="commentary">3. \(X\) has an existing table entry but \(Y\) does not. We add a \(Y\) entry
using the group number of \(X\).
</p>

<p class="commentary">4. \(Y\) has an existing table entry but \(X\) does not. We add an \(X\) entry
using the group number of \(Y\).
</p>

<p class="commentary">When a pair \((X, Y)\) is removed, we first verify that \(X\) and \(Y\) are
in the same group, then delete the table entry for \(X\). This may leave
\(Y\) in a single-member group, which could be deleted, but detecting that
situation would be inefficient, so we keep the \(Y\) entry regardless.
</p>

<p class="commentary">This code uses the Hash Core utility functions defined above.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">EquivHashTableRelationHandler</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">task</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">  </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">at2</span><span class="plain-syntax"> </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">ext</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_KIND</span><span class="plain-syntax">), </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_SET_VALENCY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">RELATION_TY_SetValency</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_DESTROY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="comment-syntax">clear</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">at</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_COPY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">), </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">at</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_SHOW</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> (</span><span class="reserved-syntax">string</span><span class="plain-syntax">) </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DESCRIPTION</span><span class="plain-syntax">), </span><span class="string-syntax">":^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="comment-syntax">flag all items by negating their group numbers</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax">=0, </span><span class="identifier-syntax">X</span><span class="plain-syntax">=</span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">&lt;=</span><span class="identifier-syntax">ext</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">++, </span><span class="identifier-syntax">X</span><span class="plain-syntax">=</span><span class="identifier-syntax">X</span><span class="plain-syntax">+3)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, -(</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">)));</span>
<span class="plain-syntax">        </span><span class="comment-syntax">display groups, unflagging them as we go</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax">=0, </span><span class="identifier-syntax">X</span><span class="plain-syntax">=</span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax">, </span><span class="identifier-syntax">fl</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">at</span><span class="plain-syntax">&lt;=</span><span class="identifier-syntax">ext</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">++, </span><span class="identifier-syntax">X</span><span class="plain-syntax">=</span><span class="identifier-syntax">X</span><span class="plain-syntax">+3, </span><span class="identifier-syntax">fl</span><span class="plain-syntax">=0) {</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;       </span><span class="comment-syntax">already visited</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, -</span><span class="identifier-syntax">fl</span><span class="plain-syntax">);  </span><span class="comment-syntax">unflag it</span>
<span class="plain-syntax">                </span><span class="comment-syntax">display the group starting with this member, but only</span>
<span class="plain-syntax">                </span><span class="comment-syntax">if there are more members in the group</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at2</span><span class="plain-syntax">=</span><span class="identifier-syntax">at</span><span class="plain-syntax">+1, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">=</span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax">+3*</span><span class="identifier-syntax">at2</span><span class="plain-syntax">: </span><span class="identifier-syntax">at2</span><span class="plain-syntax">&lt;=</span><span class="identifier-syntax">ext</span><span class="plain-syntax">: </span><span class="identifier-syntax">at2</span><span class="plain-syntax">++, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">=</span><span class="identifier-syntax">Y</span><span class="plain-syntax">+3) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">fl</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, -</span><span class="identifier-syntax">fl</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~</span><span class="identifier-syntax">i</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                            </span><span class="comment-syntax">print the saved first member</span>
<span class="plain-syntax">                            </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"  { "</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                            </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                            </span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        }</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">", "</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">" }^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_EMPTY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="comment-syntax">never empty since R(x,x) is always true</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_LOOKUP_ANY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="comment-syntax">kind of a cheat, but it's faster than searching for a better value to return</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RLANY_CAN_GET_X</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">RLANY_CAN_GET_Y</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_LOOKUP_ALL_X</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">RELS_LOOKUP_ALL_Y</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">WeakKindOfPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">LIST_OF_TY</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LIST_OF_TY_SetLength</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">LIST_ITEM_KOV_F</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HashCoreLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">X</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_LIST</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Domains of equivalence relations cannot be listed ***^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HashCoreLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">at2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HashCoreLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax">(</span><span class="identifier-syntax">task</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_TEST</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="comment-syntax">X is a loner, but could still be true if X == Y</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> == </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> == </span><span class="identifier-syntax">at2</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">) == </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_ASSERT_TRUE</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="comment-syntax">if X and Y are the same, we have nothing to do</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> == </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="comment-syntax">X and Y both missing: find a new group number and add both entries</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;        </span><span class="comment-syntax">candidate group number</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;=</span><span class="identifier-syntax">ext</span><span class="plain-syntax">: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &gt; </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">fl</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        }</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">++;          </span><span class="comment-syntax">new group number</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">) + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="comment-syntax">add X entry</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = ~</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">), </span><span class="identifier-syntax">X</span><span class="plain-syntax">); }</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="comment-syntax">add Y entry. at2 might change if X and Y have the same hash code.</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">at2</span><span class="plain-syntax"> = ~(</span><span class="identifier-syntax">HashCoreLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">), </span><span class="identifier-syntax">Y</span><span class="plain-syntax">); }</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">jump</span><span class="plain-syntax"> </span><span class="identifier-syntax">CheckResize</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="comment-syntax">X missing, Y present: add a new X entry</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = ~</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">), </span><span class="identifier-syntax">X</span><span class="plain-syntax">); }</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">jump</span><span class="plain-syntax"> </span><span class="identifier-syntax">CheckResize</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="comment-syntax">X present, Y missing: add a new Y entry</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">at2</span><span class="plain-syntax"> = ~</span><span class="identifier-syntax">at2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">), </span><span class="identifier-syntax">Y</span><span class="plain-syntax">); }</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_SINGLE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">jump</span><span class="plain-syntax"> </span><span class="identifier-syntax">CheckResize</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="comment-syntax">X and Y both present: merge higher group into lower group</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);   </span><span class="comment-syntax">higher group</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);   </span><span class="comment-syntax">lower group</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> &lt; </span><span class="identifier-syntax">fl</span><span class="plain-syntax">) { </span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">; </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">fl</span><span class="plain-syntax">; </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">at</span><span class="plain-syntax">&lt;=</span><span class="identifier-syntax">ext</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">) == </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">fl</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            .</span><span class="identifier-syntax">CheckResize</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">HashCoreCheckResize</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_ASSERT_FALSE</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="comment-syntax">if X and Y are already in different groups, we have nothing to do</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax"> || </span><span class="identifier-syntax">at2</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="comment-syntax">delete the entry for X</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">) - </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">))</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_DELETED</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP22" class="paragraph-anchor"></a><b>&#167;22. Two-In-One Hash Table Relation Handler.</b>This implements one-to-one relations, which are stored as a hash table
mapping keys to single values and vice versa. To enforce the one-to-one
constraint, we need the ability to quickly check whether a value is
present. This could be done with two separate hash tables, one mapping X to Y
and one the opposite, but in the interest of conserving memory, we use a
single table for both.
</p>

<p class="commentary">Each four-word entry \((F, E, K, V)\) consists of a flags word \(F\), an entry
key \(E\) (which may be a "key" or "value" in the hash table sense), a
corresponding key \(K\) (when \(E\) is used as a value), and a corresponding
value \(V\) (when \(E\) is used as a key). The pair of related values \((X, Y)\)
is represented as two table entries: \((F, X, _, Y)\) and \((F, Y, X, _)\).
</p>

<p class="commentary">To conserve memory when block values are used, we only create one copy
of \(X\) and/or \(Y\) to share between both entries. When adding a key or value
which already exists on either side of the relation, the previous copy will
be used. Copies are freed when they are no longer used as entry keys.
</p>

<p class="commentary">Each entry's flags word \(F\) indicates, in addition to the standard flags
<span class="extract"><span class="extract-syntax">RRF_USED</span></span> and <span class="extract"><span class="extract-syntax">RRF_DELETED</span></span>, also whether the entry contains a
corresponding key \(K\) and/or value \(V\) (<span class="extract"><span class="extract-syntax">RRF_HASX</span></span>, <span class="extract"><span class="extract-syntax">RRF_HASY</span></span>) and
whether the entry's key is the same kind of value as \(X\) or \(Y\)
(<span class="extract"><span class="extract-syntax">RRF_ENTKEYX</span></span>, <span class="extract"><span class="extract-syntax">RRF_ENTKEYY</span></span>). If both sides of the relation use the
same kind of value, or if both sides are word values, both <span class="extract"><span class="extract-syntax">RRF_ENTKEYX</span></span>
and <span class="extract"><span class="extract-syntax">RRF_ENTKEYY</span></span> will be set on every used entry.
</p>

<p class="commentary">Of particular note for this handler is the utility function <span class="extract"><span class="extract-syntax">TwoInOneDelete</span></span>,
which clears one half of an entry (given its entry key), and optionally
clears the corresponding other half stored in a different entry. That is,
given the entries \((F, X, _, Y)\) at index <span class="extract"><span class="extract-syntax">i</span></span> and \((F, Y, X, _)\) elsewhere,
<span class="extract"><span class="extract-syntax">TwoInOneDelete(rel, i, kx, ky, RRF_ENTKEYX, 1)</span></span> will clear both entries
and mark them as deleted. If, however, those entries overlap with other
pairs &mdash; say they're \((F, X, A, Y)\) and \((F, Y, X, B)\) &mdash; then the same call
to <span class="extract"><span class="extract-syntax">TwoInOneDelete</span></span> will leave us with \((F, X, A, _)\) and \((F, Y, _, B)\),
having cleared the parts corresponding to the pair \((X, Y)\) but not the
parts corresponding to the pairs \((A, X)\) and \((Y, B)\), and will not mark
either as deleted. (Such overlap is only possible when the domains of \(X\)
and \(Y\) are the same kind of value.)
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">TwoInOneHashTableRelationHandler</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">task</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> </span><span class="identifier-syntax">sym</span><span class="plain-syntax">  </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">at2</span><span class="plain-syntax"> </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> </span><span class="identifier-syntax">fl</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_KIND</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">); </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_SET_VALENCY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">RELATION_TY_SetValency</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_DESTROY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="comment-syntax">clear</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">); </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">kx</span><span class="plain-syntax"> || </span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">kx</span><span class="plain-syntax"> &amp;&amp; (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">)) || (</span><span class="identifier-syntax">ky</span><span class="plain-syntax"> &amp;&amp; (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_COPY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">); </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">X</span><span class="plain-syntax"> || </span><span class="identifier-syntax">Y</span><span class="plain-syntax">)) </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">while</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">X</span><span class="plain-syntax"> &amp;&amp; (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">)) || (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> &amp;&amp; (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">                    </span><span class="comment-syntax">copy the entry key</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">), </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">), </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="comment-syntax">update references in X/Y fields pointing here</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_HASX</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">at2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TwoInOneLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                            </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                            </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">at2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TwoInOneLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                            </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                            </span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at</span><span class="plain-syntax">--;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_SHOW</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">print</span><span class="plain-syntax"> (</span><span class="reserved-syntax">string</span><span class="plain-syntax">) </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DESCRIPTION</span><span class="plain-syntax">), </span><span class="string-syntax">":^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sym</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindComparisonFunction</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">) </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> = </span><span class="identifier-syntax">UnsignedCompare</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; (</span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">)) ==</span>
<span class="plain-syntax">                (</span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sym</span><span class="plain-syntax"> &amp;&amp; </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"  "</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">sym</span><span class="plain-syntax">) </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">" &lt;=&gt; "</span><span class="plain-syntax">; </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">" &gt;=&gt; "</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">SayKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_EMPTY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">X</span><span class="plain-syntax"> == </span><span class="constant-syntax">1</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">TwoInOneHashTableRelationHandler</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RELS_DESTROY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_LOOKUP_ANY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">RLANY_GET_X</span><span class="plain-syntax">, </span><span class="identifier-syntax">RLANY_CAN_GET_X</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TwoInOneLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">RRF_HASX</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RLANY_CAN_GET_X</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">RLANY_GET_Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">RLANY_CAN_GET_Y</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TwoInOneLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RLANY_CAN_GET_Y</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RLANY_GET_X</span><span class="plain-syntax"> </span><span class="reserved-syntax">or</span><span class="plain-syntax"> </span><span class="identifier-syntax">RLANY_GET_Y</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Lookup failed: value not found ***^"</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_LOOKUP_ALL_X</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TwoInOneLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">RRF_HASX</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_LOOKUP_ALL_Y</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TwoInOneLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">task</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RELS_LIST</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Y</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">RLIST_ALL_X</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">jump</span><span class="plain-syntax"> </span><span class="identifier-syntax">ListEntryKeys</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">RLIST_ALL_Y</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_HASX</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                .</span><span class="identifier-syntax">ListEntryKeys</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) &amp; </span><span class="identifier-syntax">fl</span><span class="plain-syntax">) == </span><span class="identifier-syntax">fl</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">), </span><span class="reserved-syntax">false</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">, </span><span class="reserved-syntax">true</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">RLIST_ALL_PAIRS</span><span class="plain-syntax">:</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">LIST_ITEM_KOV_F</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindWeakID</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">) ~= </span><span class="identifier-syntax">COMBINATION_TY</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="comment-syntax">LIST_OF_TY_InsertItem will make a deep copy of the item,</span>
<span class="plain-syntax">                </span><span class="comment-syntax">so we can reuse a single combination value here</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">): </span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">: </span><span class="identifier-syntax">at</span><span class="plain-syntax">--) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; (</span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">)) ==</span>
<span class="plain-syntax">                        (</span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">COMBINATION_ITEM_BASE</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">COMBINATION_ITEM_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">));</span>
<span class="plain-syntax">                        </span><span class="identifier-syntax">LIST_OF_TY_InsertItem</span><span class="plain-syntax">(</span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">COMBINATION_ITEM_BASE</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">COMBINATION_ITEM_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TwoInOneLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax">(</span><span class="identifier-syntax">task</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_TEST</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (~~(</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">)) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_ASSERT_TRUE</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="comment-syntax">create a new forward entry</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = ~</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">kx</span><span class="plain-syntax"> == </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> || ~~(</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">) || </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> + </span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">fl</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) { </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">), </span><span class="identifier-syntax">X</span><span class="plain-syntax">); }</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="comment-syntax">if the Y we're inserting is already there, we're done</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> == </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">                    }</span>
<span class="plain-syntax">                    </span><span class="comment-syntax">it's different, so delete the reverse entry</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">at2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TwoInOneLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">TwoInOneDelete</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">at2</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> + </span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">                </span><span class="comment-syntax">use the existing copy of X</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="comment-syntax">use the existing copy of Y if there is one</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TwoInOneLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CopyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">CreatePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">), </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="comment-syntax">delete existing reverse entry (and its own forward entry)</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">TwoInOneDelete</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">at2</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">at2</span><span class="plain-syntax"> = ~</span><span class="identifier-syntax">at2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="comment-syntax">create reverse entry</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> | (</span><span class="identifier-syntax">RRF_USED</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_HASX</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">kx</span><span class="plain-syntax"> == </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> || ~~(</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">) || </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> | </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax">, </span><span class="identifier-syntax">fl</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">TwoInOneCheckResize</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">RELS_ASSERT_FALSE</span><span class="plain-syntax">:</span>
<span class="plain-syntax">            </span><span class="comment-syntax">we only have work to do if the entry exists and has a Y which</span>
<span class="plain-syntax">            </span><span class="comment-syntax">matches the Y we're deleting</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">tmp</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tmp</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">Y</span><span class="plain-syntax">) </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">TwoInOneDelete</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">TwoInOneDelete</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> </span><span class="identifier-syntax">ekflag</span><span class="plain-syntax"> </span><span class="identifier-syntax">both</span><span class="plain-syntax">  </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> </span><span class="identifier-syntax">at2</span><span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="comment-syntax">rint "[2in1DEL at=", at, " (E=", PVField(rel, RRV_DATA_BASE + 4*at + 1), ") ekflag=", ekflag, " both=", both, "]^";</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ekflag</span><span class="plain-syntax"> == </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">both</span><span class="plain-syntax">) </span><span class="identifier-syntax">E</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="comment-syntax">delete matching Y&lt;-X entry if needed</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">both</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">at2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TwoInOneLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="identifier-syntax">TwoInOneDelete</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">at2</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> == </span><span class="identifier-syntax">at</span><span class="plain-syntax">) </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; ~</span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_HASX</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">both</span><span class="plain-syntax">) </span><span class="identifier-syntax">E</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="comment-syntax">delete matching X-&gt;Y entry if needed</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">both</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">at2</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TwoInOneLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                    </span><span class="identifier-syntax">TwoInOneDelete</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">at2</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at2</span><span class="plain-syntax"> == </span><span class="identifier-syntax">at</span><span class="plain-syntax">) </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                }</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> = </span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; ~</span><span class="identifier-syntax">RRF_HASX</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; (</span><span class="identifier-syntax">RRF_HASX</span><span class="plain-syntax">+</span><span class="identifier-syntax">RRF_HASY</span><span class="plain-syntax">)) == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="comment-syntax">entry is now empty, mark it deleted</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (((</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">) &amp;&amp; </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">kx</span><span class="plain-syntax">)) ||</span>
<span class="plain-syntax">            ((</span><span class="identifier-syntax">ky</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">kx</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">fl</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">) &amp;&amp; </span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ky</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">DestroyPV</span><span class="plain-syntax">(</span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_DELETED</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">) - </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">fl</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">TwoInOneLookUp</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">ke</span><span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax"> </span><span class="identifier-syntax">ekflag</span><span class="plain-syntax">  </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">free</span><span class="plain-syntax"> </span><span class="identifier-syntax">mask</span><span class="plain-syntax"> </span><span class="identifier-syntax">perturb</span><span class="plain-syntax"> </span><span class="identifier-syntax">flags</span><span class="plain-syntax">;</span>
<span class="comment-syntax">rint "[2in1LU rel=", rel, " ke=", ke, " E=", E, " ekf=", ekflag, ": ";</span>
<span class="plain-syntax">    </span><span class="comment-syntax">calculate a hash value for the key</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">HashKindValuePair</span><span class="plain-syntax">(</span><span class="identifier-syntax">ke</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="comment-syntax">look in the first expected slot</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">mask</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">mask</span><span class="plain-syntax">;</span>
<span class="comment-syntax">rint "hv=", hashv, ", trying ", i;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">flags</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">flags</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="comment-syntax">rint " - not found]^";</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">flags</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">ekflag</span><span class="plain-syntax">) &amp;&amp; </span><span class="identifier-syntax">TwoInOneEntryMatches</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">ke</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">)) {</span>
<span class="comment-syntax">rint " - found]^";</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="comment-syntax">not here, keep looking in sequence</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">free</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">flags</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_DELETED</span><span class="plain-syntax">) </span><span class="identifier-syntax">free</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">perturb</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hashv</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (::) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hashv</span><span class="plain-syntax">*5 + </span><span class="identifier-syntax">perturb</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">i</span><span class="plain-syntax"> = </span><span class="identifier-syntax">hashv</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">mask</span><span class="plain-syntax">;</span>
<span class="comment-syntax">rint ", ", i;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">flags</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">flags</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax">) {</span>
<span class="comment-syntax">rint " - not found]^";</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">free</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">return</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">free</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> ~</span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">flags</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">ekflag</span><span class="plain-syntax">) &amp;&amp; </span><span class="identifier-syntax">TwoInOneEntryMatches</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">ke</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">)) {</span>
<span class="comment-syntax">rint " - found]^";</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">free</span><span class="plain-syntax"> &lt; </span><span class="constant-syntax">0</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">flags</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_DELETED</span><span class="plain-syntax">)) </span><span class="identifier-syntax">free</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">ifdef</span><span class="plain-syntax"> </span><span class="identifier-syntax">TARGET_ZCODE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">log_shift</span><span class="plain-syntax"> </span><span class="identifier-syntax">perturb</span><span class="plain-syntax"> </span><span class="identifier-syntax">MINUS_RRP_PERTURB_SHIFT</span><span class="plain-syntax"> -&gt; </span><span class="identifier-syntax">perturb</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">ifnot</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        @</span><span class="identifier-syntax">ushiftr</span><span class="plain-syntax"> </span><span class="identifier-syntax">perturb</span><span class="plain-syntax"> </span><span class="identifier-syntax">RRP_PERTURB_SHIFT</span><span class="plain-syntax"> </span><span class="identifier-syntax">perturb</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        #</span><span class="identifier-syntax">endif</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">TwoInOneCheckResize</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax">  </span><span class="identifier-syntax">filled</span><span class="plain-syntax"> </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> </span><span class="identifier-syntax">newext</span><span class="plain-syntax"> </span><span class="identifier-syntax">temp</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> </span><span class="identifier-syntax">F</span><span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax"> </span><span class="identifier-syntax">X</span><span class="plain-syntax"> </span><span class="identifier-syntax">Y</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">filled</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">) + </span><span class="constant-syntax">1</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">filled</span><span class="plain-syntax"> &gt;= (</span><span class="identifier-syntax">ext</span><span class="plain-syntax"> - </span><span class="identifier-syntax">filled</span><span class="plain-syntax">) * </span><span class="identifier-syntax">RRP_CROWDED_IS</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="comment-syntax">copy entries to temporary space</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">temp</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FlexAllocate</span><span class="plain-syntax">(</span><span class="identifier-syntax">ext</span><span class="plain-syntax"> * (4*</span><span class="identifier-syntax">WORDSIZE</span><span class="plain-syntax">), </span><span class="identifier-syntax">TEXT_TY</span><span class="plain-syntax">, </span><span class="identifier-syntax">BLK_FLAG_WORD</span><span class="plain-syntax">+</span><span class="identifier-syntax">BLK_FLAG_MULTIPLE</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">ext</span><span class="plain-syntax">*4: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">InitialisePVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax">+</span><span class="identifier-syntax">i</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="comment-syntax">resize and clear our data</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ext</span><span class="plain-syntax"> &gt;= </span><span class="identifier-syntax">RRP_LARGE_IS</span><span class="plain-syntax">) </span><span class="identifier-syntax">newext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> * </span><span class="identifier-syntax">RRP_RESIZE_LARGE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">newext</span><span class="plain-syntax"> = </span><span class="identifier-syntax">ext</span><span class="plain-syntax"> * </span><span class="identifier-syntax">RRP_RESIZE_SMALL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">SetPVFieldCapacity</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="identifier-syntax">newext</span><span class="plain-syntax">*4);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_STORAGE</span><span class="plain-syntax">, </span><span class="identifier-syntax">newext</span><span class="plain-syntax"> - </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_FILLED</span><span class="plain-syntax">, </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_USED</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">newext</span><span class="plain-syntax">*4: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax">+</span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="comment-syntax">copy entries back from temporary space</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">kind_id</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_KIND</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">kx</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">); </span><span class="identifier-syntax">ky</span><span class="plain-syntax"> = </span><span class="identifier-syntax">KindConstructorTerm</span><span class="plain-syntax">(</span><span class="identifier-syntax">kind_id</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="identifier-syntax">i</span><span class="plain-syntax">=0: </span><span class="identifier-syntax">i</span><span class="plain-syntax">&lt;</span><span class="identifier-syntax">ext</span><span class="plain-syntax">: </span><span class="identifier-syntax">i</span><span class="plain-syntax">++) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">F</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> == </span><span class="constant-syntax">0</span><span class="plain-syntax"> || (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_DELETED</span><span class="plain-syntax">)) </span><span class="reserved-syntax">continue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">E</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">X</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Y</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVLongBlockField</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">, </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">i</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">F</span><span class="plain-syntax"> &amp; </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">) </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TwoInOneLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">kx</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYX</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TwoInOneLookUp</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">ky</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRF_ENTKEYY</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">at</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">0</span><span class="plain-syntax">) { </span><span class="reserved-syntax">print</span><span class="plain-syntax"> </span><span class="string-syntax">"*** Duplicate entry while resizing ***^"</span><span class="plain-syntax">; </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">; }</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">at</span><span class="plain-syntax"> = ~</span><span class="identifier-syntax">at</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax">, </span><span class="identifier-syntax">F</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">2</span><span class="plain-syntax">, </span><span class="identifier-syntax">X</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">WritePVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">3</span><span class="plain-syntax">, </span><span class="identifier-syntax">Y</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="comment-syntax">done with temporary space</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">FlexFree</span><span class="plain-syntax">(</span><span class="identifier-syntax">temp</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">];</span>

<span class="plain-syntax">[ </span><span class="identifier-syntax">TwoInOneEntryMatches</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">at</span><span class="plain-syntax"> </span><span class="identifier-syntax">ke</span><span class="plain-syntax"> </span><span class="identifier-syntax">E</span><span class="plain-syntax">  </span><span class="identifier-syntax">ce</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">ce</span><span class="plain-syntax"> = </span><span class="identifier-syntax">PVField</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RRV_DATA_BASE</span><span class="plain-syntax"> + </span><span class="constant-syntax">4</span><span class="plain-syntax">*</span><span class="identifier-syntax">at</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">KindConformsTo_POINTER_VALUE_TY</span><span class="plain-syntax">(</span><span class="identifier-syntax">ke</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ComparePV</span><span class="plain-syntax">(</span><span class="identifier-syntax">ce</span><span class="plain-syntax">, </span><span class="identifier-syntax">E</span><span class="plain-syntax">) ~= </span><span class="constant-syntax">0</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">ce</span><span class="plain-syntax"> ~= </span><span class="identifier-syntax">E</span><span class="plain-syntax">) </span><span class="reserved-syntax">rfalse</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">rtrue</span><span class="plain-syntax">;</span>
<span class="plain-syntax">];</span>
</pre>
<p class="commentary firstcommentary"><a id="SP23" class="paragraph-anchor"></a><b>&#167;23. Empty.</b>This implements the "empty" adjective. We can always check whether a relation
is empty. For most relation types, we can cause the relation to become empty by
removing all pairs: but this is impossible for equivalence relations, which are
never empty, since any \(X\) is equivalent to itself. And we can never force a
relation to become non-empty, since that would require making up data.
</p>

<p class="commentary">In any case, the implementation is delegated to the relation handler.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">[ </span><span class="identifier-syntax">RELATION_TY_Empty</span><span class="plain-syntax"> </span><span class="identifier-syntax">rel</span><span class="plain-syntax"> </span><span class="identifier-syntax">set</span><span class="plain-syntax">  </span><span class="identifier-syntax">handler</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">handler</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RlnGetF</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RR_HANDLER</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">handler</span><span class="plain-syntax">(</span><span class="identifier-syntax">rel</span><span class="plain-syntax">, </span><span class="identifier-syntax">RELS_EMPTY</span><span class="plain-syntax">, </span><span class="identifier-syntax">set</span><span class="plain-syntax">);</span>
<span class="plain-syntax">];</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="cmtm.html">&#10094;</a></li><li class="progresssection"><a href="dftm.html">dftm</a></li><li class="progresssection"><a href="sttm.html">sttm</a></li><li class="progresssection"><a href="uttm.html">uttm</a></li><li class="progresssection"><a href="prgrp.html">prgrp</a></li><li class="progresssection"><a href="mttm.html">mttm</a></li><li class="progresssection"><a href="srtm.html">srtm</a></li><li class="progresssection"><a href="tbtm.html">tbtm</a></li><li class="progresssection"><a href="mstck.html">mstck</a></li><li class="progresssection"><a href="rltm.html">rltm</a></li><li class="progresssection"><a href="actm.html">actm</a></li><li class="progresssection"><a href="prtm.html">prtm</a></li><li class="progresssection"><a href="flx.html">flx</a></li><li class="progresssection"><a href="blckv.html">blckv</a></li><li class="progresssection"><a href="kntm.html">kntm</a></li><li class="progresssection"><a href="txtm.html">txtm</a></li><li class="progresssection"><a href="chtm.html">chtm</a></li><li class="progresssection"><a href="rgtm.html">rgtm</a></li><li class="progresssection"><a href="lstm.html">lstm</a></li><li class="progresssection"><a href="cmtm.html">cmtm</a></li><li class="progresscurrent">rkt</li><li class="progresssection"><a href="rltns.html">rltns</a></li><li class="progresssection"><a href="prtm2.html">prtm2</a></li><li class="progresssection"><a href="rttm.html">rttm</a></li><li class="progressnext"><a href="rltns.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

